package com.zzyl.serve.service.impl;

import java.util.List;
import com.zzyl.common.utils.DateUtils;
import com.zzyl.serve.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.serve.mapper.NursingProjectMapper;
import com.zzyl.serve.domain.NursingProject;
import com.zzyl.serve.service.INursingProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * 护理项目Service业务层处理
 *
 * @author ruoyi
 * @date 2024-09-30
 */
@Service
public class NursingProjectServiceImpl extends ServiceImpl<NursingProjectMapper, NursingProject> implements INursingProjectService
{
    @Autowired
    private NursingProjectMapper nursingProjectMapper;

    /**
     * 查询护理项目
     *
     * @param id 护理项目主键
     * @return 护理项目
     */
    @Override
    public NursingProject selectNursingProjectById(Long id)
    {
        return getById(id);
    }

    /**
     * 查询护理项目列表
     *
     * @param nursingProject 护理项目
     * @return 护理项目
     */
    @Override
    public List<NursingProject> selectNursingProjectList(NursingProject nursingProject)
    {
        return nursingProjectMapper.selectNursingProjectList(nursingProject);
    }

    /**
     * 新增护理项目
     *
     * @param nursingProject 护理项目
     * @return 结果
     */
    @Override
    public int insertNursingProject(NursingProject nursingProject)
    {
        return save(nursingProject) ? 1 : 0;
    }

    /**
     * 修改护理项目
     *
     * @param nursingProject 护理项目
     * @return 结果
     */
    @Override
    public int updateNursingProject(NursingProject nursingProject)
    {
        return updateById(nursingProject) ? 1 : 0;
    }

    /**
     * 批量删除护理项目
     *
     * @param ids 需要删除的护理项目主键
     * @return 结果
     */
    @Override
    public int deleteNursingProjectByIds(Long[] ids)
    {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除护理项目信息
     *
     * @param id 护理项目主键
     * @return 结果
     */
    @Override
    public int deleteNursingProjectById(Long id)
    {
        return removeById(id) ? 1 : 0;
    }

    @Override
    public List<NursingProjectVo> queryAll() {
//       //1、查询所有启用护理项目
//     //  select id,[name](file://D:\项目1中州养老\04-项目一中州养老AI若依版\06.%20入住办理-后端接口开发\资料\入住办理后端初始代码\git\zzyl\zzyl-ui\vue.config.js#L9-L9) from nursing_project where [status](file://D:\项目1中州养老\04-项目一中州养老AI若依版\06.%20入住办理-后端接口开发\资料\入住办理后端初始代码\git\zzyl\zzyl-quartz\src\main\java\com\zzyl\quartz\domain\SysJob.java#L53-L54) = 1
//       List<NursingProject> List = this.lambdaQuery()
//               .select(NursingProject::getId, NursingProject::getName)
//               .eq(NursingProject::getStatus, 1)
//               .list();
//
//       //2、封装成List<NursingProjectVo>返回
//        List<NursingProjectVo> voList= List.stream()
//                .map(p -> NursingProjectVo.builder()
//                .value(String.valueOf(p.getId()))
//                .label(p.getName())
//                .build()).collect(Collectors.toList());
//           return voList;
      return this.getBaseMapper().queryNursingProjectVoList();

    }

}
